package ArrayPackage2;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Lzm
 * @version 1.0
 */
public class removeElement_ {
  public static void main(String[] args) {
    int[] nums = new int[]{3,2,2,3};
    int val = 3;
    int result = removeElement(nums, val);
    System.out.println(result);
  }

  public static int removeElement(int[] nums, int val) {
    if (nums == null || nums.length == 0){
      return 0;
    }
    List<Integer> resultList = new ArrayList<>();
    for (int num : nums) {
      if (num != val){
        resultList.add(num);
      }
    }
    int[] result = new int[resultList.size()];
    int index = 0;
    for (Integer integer : resultList) {
      System.out.println(integer);
    }
    return resultList.size();
  }
}
